<script src="/public_html/js/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="/public_html/js/jquery-ui-1.8.10.custom.min.js" type="text/javascript"></script>

<script type="text/javascript">
jQuery(function(){
    jQuery("#sortable").sortable({
        axis: "y"
        //, revert: true
        , containment: "parent"
        , tolerance: "pointer"
        , update: function(event, ui) {
            jQuery("#idsort").val(jQuery("#sortable").sortable("serialize"));
            }
        });
});
</script>
<?php if( !empty( $arFiles ) ): ?>
    <div id="sortable">
    <?php foreach( $arFiles as $obj ): ?>
        <div id="id_<?php echo $obj->getId()?>" class="sort_product">
            <div class="sort_picture">
                <?php echo image_tag( '/images/gallery/tiny/' . $obj->getUname()); ?>
            </div>
            <div class="sort_actions">
                <?php echo link_to(
                                image_tag(
                                    'delete.png'
                                    , array(
                                        'alt' => __('Delete')
                                        , 'title' => __('Delete')
                                    )
                                )
                                , 'gallery/removefile?id=' . $gallery->getId() . '&uname=' . $obj->getNameforurl()
                                , array(
                                    'confirm' => __('Are you sure?!')
                                )
                ) ?>
                <?php echo link_to(image_tag('/sf/sf_admin/images/edit_icon.png'
                                            , array('border' => 0))
                                , 'files/editfile?id=' . $obj->getId() . '&parentid=' . $sf_params->get('id'));
                ?>
            </div>
        </div>
    <?php endforeach; ?>
    </div>
    <?php echo input_hidden_tag("idsort", "") ?>
<?php endif; ?>
<div style="clear: both;"></div>
<?php echo link_to('upload new photo', 'gallery/photos?id='.$gallery->getId());?>

